#include "gtest/gtest.h"
#include "helper/object/ObjectInterface.h"
#include "helper/ScopedMemPtr.h"

using namespace helper;
using namespace object;

TEST(ObjectFactoryTest, testDefaultCreaterFunction){
	const char * expect = "string";
	ObjectFactory * factory = ObjectFactory::createDefault();
	ASSERT_TRUE(nullptr != factory);
	auto * str = factory->createString(expect);
	ASSERT_EQ(*str, *(factory->createString(expect)));

	ASSERT_NE(*str, *(factory->createString("string1")));
}

TEST(ObjectFactoryTest, testDefaultFactoryEqual){
	const char * expect = "string";
	ObjectFactory * factory = ObjectFactory::createDefault();
	ASSERT_TRUE(nullptr != factory);
	ScopedMemPtr<String> str = factory->createString(expect);

	ObjectFactory * globalFactory = DefaultObjectFactory::instance().getPtr();
	ASSERT_TRUE(nullptr != globalFactory);
	ScopedMemPtr<String> gStr = globalFactory->createString(expect);

	ASSERT_EQ(*str, *gStr);

	ScopedMemPtr<String> gStrNotEqual = globalFactory->createString("string1");
	ASSERT_NE(*str, *gStrNotEqual);
	
}
